{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "# 原理：dstImg = src1*alpha + src2*(1-alpha)\n",
    "img0 = cv2.imread('image0.jpg',1)\n",
    "img1 = cv2.imread('image1.jpg',1)\n",
    "imgInfo = img0.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "# 抠图ROI\n",
    "roiHeight = int(height/2)\n",
    "roiWidth = int(width/2)\n",
    "img0ROI = img0[0:roiHeight,0:roiWidth]\n",
    "img1ROI = img1[0:roiHeight,0:roiWidth]\n",
    "dstImg = np.zeros((roiHeight,roiWidth,3),np.uint8)\n",
    "# 权重相加 参数1：src1 参数2：src1对应的alpha 参数3：src2 参数4：src2对应的alpha\n",
    "dstImg = cv2.addWeighted(img0ROI,0.5,img1ROI,0.5,0)\n",
    "cv2.imshow('dstImg',dstImg)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
